namespace 作业6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public List<ItemBean> list = new List<ItemBean>();
        private void dataList()
        {
            for (int i = 0; i < 10; ++i)
            {
                ItemBean item = new ItemBean();
                item.postion = i.ToString();
                item.item1 = "Listitem1-" + i;
                item.item2 = "Listitem2-" + i;
                item.item3 = "Listitem3-" + i;
                list.Add(item);
            }
            dataGridView1.DataSource = list;
            //DataGridView的列name和对象成员的绑定
            dataGridView1.Columns["Column1"].DataPropertyName = "postion";
            dataGridView1.Columns["Column2"].DataPropertyName = "item1";
            dataGridView1.Columns["Column3"].DataPropertyName = "item2";
            dataGridView1.Columns["Column4"].DataPropertyName = "item3";
        }
        public class ItemBean
        {
            public string postion { get; set; }
            public string item1 { get; set; }
            public string item2 { get; set; }
            public string item3 { get; set; }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.dataList();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}